﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ArbabTravelsERP.DAL;

namespace ArbabTravelsERP.Models
{
    public class All_Master
    {
        DAL.Master dal = new Master();

        public SelectList GetCountryStateCity()
        {
            DataTable dtCountryStateCity = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtCountryStateCity"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtCountryStateCity"] = dal.GetCountryStateCity();
                }
                dtCountryStateCity = ((DataTable)System.Web.HttpContext.Current.Cache["dtCountryStateCity"]).DefaultView.ToTable(true, new string[] { "Country_Code", "Country_Name" });

                var results = from row in dtCountryStateCity.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<string>("Country_Code")),
                                  Text = row.Field<string>("Country_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtCountryStateCity.Dispose();
            }
        }
         
        
        public SelectList GetAvailingType()
        {
            DataTable dtAvailingType = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtAvailingType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtAvailingType"] = dal.GetAvailingType();
                }
                dtAvailingType = ((DataTable)System.Web.HttpContext.Current.Cache["dtAvailingType"]).DefaultView.ToTable(true, new string[] { "Availing_Type_id", "Availing_Type" });

                var results = from row in dtAvailingType.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Availing_Type_Id")),
                                  Text = row.Field<string>("Availing_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtAvailingType.Dispose();
            }
        }

        public SelectList GetSource()
        {
            DataTable dtSource = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtSource"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtSource"] = dal.GetSource();
                }
                dtSource = ((DataTable)System.Web.HttpContext.Current.Cache["dtSource"]).DefaultView.ToTable(true, new string[] { "SOURCE_ID", "Source_Name" });

                var results = from row in dtSource.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("SOURCE_ID")),
                                  Text = row.Field<string>("Source_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtSource.Dispose();
            }
        }

        public SelectList GetStatus()
        {
            DataTable dtStatus = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtStatus"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtStatus"] = dal.GetStatus();
                }
                dtStatus = ((DataTable)System.Web.HttpContext.Current.Cache["dtStatus"]).DefaultView.ToTable(true, new string[] { "STATUS_ID", "Status_Name" });

                var results = from row in dtStatus.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("STATUS_ID")),
                                  Text = row.Field<string>("Status_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtStatus.Dispose();
            }
        }

        public SelectList GetRequirementType()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["RequirementType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["RequirementType"] = dal.GetRequirement();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["RequirementType"]).DefaultView.ToTable(true, new string[] { "Requirement_Type_Id", "Requirement_Type" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Requirement_Type_Id")),
                                  Text = row.Field<string>("Requirement_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetVisaType()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["VisaType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["VisaType"] = dal.GetVisaType();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["VisaType"]).DefaultView.ToTable(true, new string[] { "VISA_ID", "VISA_NUMBER" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("VISA_ID")),
                                  Text = row.Field<string>("VisaType")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetMaritalStatus()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["MaritalStatus"] == null)
                {
                    System.Web.HttpContext.Current.Cache["MaritalStatus"] = dal.GetMaritalStatus();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["MaritalStatus"]).DefaultView.ToTable(true, new string[] { "MARITAL_STATUS_ID", "MARITAL_STATUS" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("MARITAL_STATUS_ID")),
                                  Text = row.Field<string>("MARITAL_STATUS")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetNationality()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Nationality"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Nationality"] = dal.GetNationality();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Nationality"]).DefaultView.ToTable(true, new string[] { "NATIONALITY_ID", "NATIONALITY" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("NATIONALITY_ID")),
                                  Text = row.Field<string>("NATIONALITY")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetLocation()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Location"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Location"] = dal.GetLocation();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Location"]).DefaultView.ToTable(true, new string[] { "CITY_CODE", "CITY_NAME" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<string>("CITY_CODE")),
                                  Text = row.Field<string>("CITY_NAME")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetReligion()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Religion"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Religion"] = dal.GetReligion();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Religion"]).DefaultView.ToTable(true, new string[] { "Religion_Id", "Religion_Name" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Religion_Id")),
                                  Text = row.Field<string>("Religion_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetLanguage()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Language"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Language"] = dal.GetLanguages();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Language"]).DefaultView.ToTable(true, new string[] { "Language_Id", "LANGUAGE_NAME" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Language_Id")),
                                  Text = row.Field<string>("LANGUAGE_NAME")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetAddressType()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["AddressType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["AddressType"] = dal.GetAddressType();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["AddressType"]).DefaultView.ToTable(true, new string[] { "Address_Type_ID", "Address_Type" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Address_Type_ID")),
                                  Text = row.Field<string>("Address_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetUniversity()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["University"] == null)
                {
                    System.Web.HttpContext.Current.Cache["University"] = dal.GetUniversity();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["University"]).DefaultView.ToTable(true, new string[] { "University_ID", "University_Name" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("University_ID")),
                                  Text = row.Field<string>("University_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetCompany()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Company"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Company"] = dal.GetCompany();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Company"]).DefaultView.ToTable(true, new string[] { "Company_ID", "Company_Name" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Company_ID")),
                                  Text = row.Field<string>("Company_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetDesignation()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Designation"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Designation"] = dal.GetDesignation();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Designation"]).DefaultView.ToTable(true, new string[] { "Designation_ID", "Designation_Name" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Designation_ID")),
                                  Text = row.Field<string>("Designation_Name")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetIndustry()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Industry"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Industry"] = dal.GetIndustry();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Industry"]).DefaultView.ToTable(true, new string[] { "Industry_ID", "Industry_Type" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Industry_ID")),
                                  Text = row.Field<string>("Industry_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetEducation()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Education"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Education"] = dal.GetEducation();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Education"]).DefaultView.ToTable(true, new string[] { "EDUCATION_TYPE_ID", "EDUCATION_TYPE" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("EDUCATION_TYPE_ID")),
                                  Text = row.Field<string>("EDUCATION_TYPE")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetSpecialization()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Specialization"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Specialization"] = dal.GetSpecialization();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Specialization"]).DefaultView.ToTable(true, new string[] { "Specialization_ID", "Specialization_Type" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("Specialization_ID")),
                                  Text = row.Field<string>("Specialization_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetVehicleType()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["VehicleType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["VehicleType"] = dal.GetVehicleType();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["VehicleType"]).DefaultView.ToTable(true, new string[] { "VEHICLE_TYPE_ID", "VEHICLE_TYPE" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("VEHICLE_TYPE_ID")),
                                  Text = row.Field<string>("VEHICLE_TYPE")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetBranch()
        {
            DataTable dt = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["Branch"] == null)
                {
                    System.Web.HttpContext.Current.Cache["Branch"] = dal.GetBranch();
                }
                dt = ((DataTable)System.Web.HttpContext.Current.Cache["Branch"]).DefaultView.ToTable(true, new string[] { "BRANCH_CODE", "BRANCH_NAME" });

                var results = from row in dt.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<string>("BRANCH_CODE")),
                                  Text = row.Field<string>("BRANCH_NAME")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dt.Dispose();
            }
        }

        public SelectList GetUserType()
        {
            DataTable dtUserType = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtUserType"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtUserType"] = dal.GetUserType();
                }
                dtUserType = ((DataTable)System.Web.HttpContext.Current.Cache["dtUserType"]).DefaultView.ToTable(true, new string[] { "USER_Type_id", "USER_Type" });

                var results = from row in dtUserType.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("USER_Type_id")),
                                  Text = row.Field<string>("USER_Type")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtUserType.Dispose();
            }
        }

        public SelectList GetModeOfInterview()
        {
            DataTable dtModeOfInterview = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtModeOfInterview"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtModeOfInterview"] = dal.GetModeOfInterview();
                }
                dtModeOfInterview = ((DataTable)System.Web.HttpContext.Current.Cache["dtModeOfInterview"]).DefaultView.ToTable(true, new string[] { "INTERVIEW_MODE_ID", "INTERVIEW_MODE" });

                var results = from row in dtModeOfInterview.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("INTERVIEW_MODE_ID")),
                                  Text = row.Field<string>("INTERVIEW_MODE")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtModeOfInterview.Dispose();
            }
        }

        public SelectList GetCurrency()
        {
            DataTable dtCurrency = new DataTable();
            try
            {
                if (System.Web.HttpContext.Current.Cache["dtCurrency"] == null)
                {
                    System.Web.HttpContext.Current.Cache["dtCurrency"] = dal.GetCurrency();
                }
                dtCurrency = ((DataTable)System.Web.HttpContext.Current.Cache["dtCurrency"]).DefaultView.ToTable(true, new string[] { "CURRENCY_ID", "CURRENCY_NAME" });

                var results = from row in dtCurrency.AsEnumerable()
                              select new
                              {
                                  Value = Convert.ToString(row.Field<Int32>("CURRENCY_ID")),
                                  Text = row.Field<string>("CURRENCY_NAME")
                              };
                return new SelectList(results, "Value", "Text");
            }
            finally
            {
                dtCurrency.Dispose();
            }
        }

    }
}